<?php
defined('IN_YuLin') || exit('NO PERMIT!');
$table = Table('user_mail');
//删除
if($a == 'del'){
    !is_array($_POST['del_ids']) and $ids = explode(',', $_POST['del_ids']);
    foreach($_POST['del_ids'] as $key => $val) $ids[$key] = intval($val);
    $db->exec('DELETE FROM '.$table.' WHERE id in ('.implode(",", $ids).')');
    AjaxReturn(['status'=>'1','msg'=>'删除成功']);
}
//标为已读
if($a == 'read'){
    !is_array($_POST['read_ids']) and $ids = explode(',', $_POST['read_ids']);
    foreach($_POST['read_ids'] as $key => $val) $ids[$key] = intval($val);
    $res = $db->exec('UPDATE '.$table.' SET '.CreateUpdateSql(array('is_read'=>"1")).' WHERE id in ('.implode(",", $ids).')');
    AjaxReturn(['status'=>'1','msg'=>'标注成功']);
}
//列表
$where =  'from '.$table.' where 1=1 and recipient_uid='.$_SESSION['uid'];
$tmp = $db->getrow('SELECT COUNT(1) AS p '.$where);
$page = max(1,intval($_GET['page']));
$size = 10;
$limit    = ' LIMIT '.($page - 1) * $size.','.$size;
$url = '?m='.$m.'&c='.$c.'&a='.$a;
$orderby = ' ORDER BY id ASC ';
$data = $db->getall('SELECT * '.$where.$orderby.$limit);
$multi = Multi($url,$page,$tmp['p'],$size);

$tpl->display($m.'/'.$c);
?>